package com.wffz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wffz.comm.utils.CommUtils;
import com.wffz.mapper.WffzConfigMapper;
import com.wffz.po.WffzConfig;
import com.wffz.service.WffzConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author sunlei
 * @className WffzConfigServiceImpl
 * @Description
 * @date 2023-03-03 21:44
 **/
@Service
@Slf4j
public class WffzConfigServiceImpl implements WffzConfigService {

    @Resource
    private WffzConfigMapper mapper;

    @Override
    public WffzConfig getConfigByKey(String key) {
        QueryWrapper<WffzConfig> wrapper = new QueryWrapper<>();
        wrapper.eq("config_key", key);
        List<WffzConfig> list = mapper.selectList(wrapper);
        if (CommUtils.isNotEmptyList(list)) {
            return list.get(0);
        } else {
            return null;
        }
    }
}
